export default {
  name: 'login',
  data () {
  	 return {
        username:'',
        password:'',
        lodding:false
  	 }
  },
  mounted() {
    this.$store.commit('signOut');
    this.$store.commit('setHeadShow',false);
    document.onkeydown=(event)=>{
        if(event.keyCode==13){
            this.submitForm();
        }
    }
  },
  methods:{
    submitForm(){
        if(this.username==''||this.password==''){
            this.$message.error('登陆名/密码不能为空');
            return;
        };
        this.lodding=true;
        this.$http({
          method: 'post',
          url: '/site/login',
          data: {
            username:this.username,
            password:this.password
          },
        }).then((data) => {
            this.password='';
            this.lodding=false;
            this.$store.commit('setUsers',data.data.data);
            this.$router.push('/planList');
        })
        .catch(function (error) {
          console.log(error);
        });
    }
  }
}